package logic.ui.uieditscene
{
	import common.manager.ObserverEvt;
	
	import component.show.containers.SimpleBtn;
	import component.show.control.UISprite;
	
	import fl.controls.Button;
	
	import flash.events.MouseEvent;

	public class TopBar extends UISprite
	{
		public static const NAME : String = "TopBar";
		
		public static const OPENUIXML : String = "TopBar_OpenUIXML";
		public static const SAVEUIXML : String ="TopBar_SaveUIXML";
		public static const DELUICOM : String = "TopBar_DelUICom";
		public static const SORTUP : String = "TopBar_SortUp";
		public static const SORTDOWN : String = "TopBar_SortDown";
		public static const SCANUITREE : String = "TopBar_ScanUITree";
		
		private var m_btnOpen : SimpleBtn ;
		private var m_btnSave : SimpleBtn;
		private var m_btnDel : SimpleBtn;
		private var m_btnSortUp : SimpleBtn;
		private var m_btnSortDown : SimpleBtn;
		private var m_btnScanUITree : SimpleBtn;
		
		public function TopBar()
		{
			super(NAME);
			
			this.opaqueBackground = 0x000000;
			
			m_btnOpen = collection["BtnOpen"];
			m_btnSave = collection["BtnSave"];
			m_btnDel = collection["BtnDel"];
			m_btnSortDown = collection["BtnSortDown"];
			m_btnSortUp = collection["BtnSortUp"];
			m_btnScanUITree = collection["BtnUITree"];
			
			m_btnOpen.addEventListener(MouseEvent.CLICK,onClickOpenBtn);
			m_btnSave.addEventListener(MouseEvent.CLICK,onClickSaveBtn);
			m_btnDel.addEventListener(MouseEvent.CLICK,onClicDelBtn);
			m_btnSortUp.addEventListener(MouseEvent.CLICK,onClickSortUpBtn);
			m_btnSortDown.addEventListener(MouseEvent.CLICK,onClickSortDownBtn);
			m_btnScanUITree.addEventListener(MouseEvent.CLICK,onClickScanUITreeBtn);
		}
		
		public  override function destory() : void
		{
			m_btnOpen.removeEventListener(MouseEvent.CLICK,onClickOpenBtn);
			m_btnSave.removeEventListener(MouseEvent.CLICK,onClickSaveBtn);
			m_btnDel.removeEventListener(MouseEvent.CLICK,onClicDelBtn);
			m_btnSortUp.removeEventListener(MouseEvent.CLICK,onClickSortUpBtn);
			m_btnSortDown.removeEventListener(MouseEvent.CLICK,onClickSortDownBtn);
			m_btnScanUITree.removeEventListener(MouseEvent.CLICK,onClickScanUITreeBtn);
			
			m_btnDel = null;
			m_btnOpen = null;
			m_btnSave = null;
			m_btnScanUITree = null;
			m_btnSortDown = null;
			m_btnSortUp = null;
		}
		
		private function onClickOpenBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(OPENUIXML);
		}
		
		private function onClickSaveBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(SAVEUIXML);	
		}
		
		private function onClicDelBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(DELUICOM);
		}
		
		private function onClickSortUpBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(SORTUP);
		}
		
		private function onClickSortDownBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(SORTDOWN);
		}
		
		private function onClickScanUITreeBtn(evt : MouseEvent) : void
		{
			ObserverEvt.Send(SCANUITREE);
		}
		
		public function Resize(w:Number,h:Number) : void
		{
			this.width = w;
			this.height = h;
		}
	}
}